package com.supergzt.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 张钧
 * @Description
 * @create 2022-10-24 19:19
 */
@Configuration
@Data
@ConfigurationProperties(prefix = "redisson")
public class RedissonConfiguration {

	private String address;

	private String password;

	private Integer database;

	@Bean
	public RedissonClient getRedisson() {
		Config config = new Config();
		config.useSingleServer().
				setAddress(address).setPassword(password).setDatabase(database);
		config.setCodec(new JsonJacksonCodec());
		return Redisson.create(config);
	}
}
